#include <stdio.h>
#include <math.h>

#define Epsilon 1.0E-6

int main()
{
    float num,pre,this;
    printf("输入要求平方根的数:");
    do
    {
        scanf("%f",&num);
    } while (num < 0);
    if(num == 0)
    printf("平方根为0");
    else
    {
        this = 1;
        do
        {
            pre = this;
            this = (pre + num / pre) / 2;
        }while(fabs(pre - this) > Epsilon);
    }
    printf("平方根为%f\n",this);    
}